﻿Public Class ctrThongTin

    Private Sub ShowTab()
        Dim i As Integer = frmMain.TabControl1.TabCount - 1
        frmMain.TabControl1.SelectTab(i)
    End Sub

    Private Function ExistsTab(ByVal str As String) As Integer
        For i = 0 To frmMain.TabControl1.TabCount() - 1 Step 1
            If (frmMain.TabControl1.TabPages(i).Text = str) Then
                Return i
            End If
        Next
        Return -1
    End Function

    Private Sub btnHuonDan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuonDan.Click
        btnHuonDan.ForeColor = Color.White
        btnHuonDan.BackColor = Color.Blue
        btnThongTinPM.ForeColor = Color.Blue
        btnThongTinPM.BackColor = Color.White

        Dim str As String = "Hướng dẫn sử dụng"
        If (ExistsTab(str) = -1) Then
            Dim tab As TabPage = New TabPage()
            frmMain.TabControl1.Controls.Add(tab)
            tab.Text = str

            Dim ctr As ctrHuongDan = New ctrHuongDan()
            tab.Controls.Add(ctr)
            ctr.Dock = DockStyle.Fill

            ShowTab()
        Else
            frmMain.TabControl1.SelectTab(ExistsTab(str))
        End If
    End Sub

    Private Sub btnThongTinPM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThongTinPM.Click
        btnHuonDan.ForeColor = Color.Blue
        btnHuonDan.BackColor = Color.White
        btnThongTinPM.ForeColor = Color.White
        btnThongTinPM.BackColor = Color.Blue

        Dim str As String = "Giới thiệu phần mềm"
        If (ExistsTab(str) = -1) Then
            Dim tab As TabPage = New TabPage()
            frmMain.TabControl1.Controls.Add(tab)
            tab.Text = str

            Dim ctr As ctrGioiThieu = New ctrGioiThieu()
            tab.Controls.Add(ctr)
            ctr.Dock = DockStyle.Fill

            ShowTab()
        Else
            frmMain.TabControl1.SelectTab(ExistsTab(str))
        End If
    End Sub
End Class
